package cave.renderer;

import java.util.ArrayList;

import cave.utils.IntArray;

public class RenderMsgQueue {
	
	/** MESSAGE DESCRIPTIONS
	 * 
	 * - Messages from game thread to renderer:
	 * 
	 *   - MSG_CREATETEXTURE
	 * 		0: msg id
	 * 		1: index of image data array in obj params
	 * 		2: width
	 * 		3: height
	 * 		4: wrap mode
	 * 		5: filtering
	 * 
	 * 	 - MSG_DESTROYTEXTURE
	 * 		0: msg id
	 * 		1: texture index
	 * 
	 *   - MSG_RESOURCESCREATED
	 *		0: msg id   
	 * 
	 * 
	 **/
	
	
	public static final int MSG_CREATETEXTURE = 0;
	public static final int MSG_DESTROYTEXTURE = 1;
	public static final int MSG_RESOURCESCREATED = 2;
	
	private IntArray intData;
	private ArrayList<Object> objectData;
	
	public RenderMsgQueue() {
		intData = new IntArray(20);
		objectData = new ArrayList<Object>(20);
	}
	
	public void addMessages(RenderMsgQueue msgQueue) {
		int numIntData = msgQueue.getIntData().size();
		for (int i = 0; i < numIntData; ++i) {
			intData.add(msgQueue.getIntData().get(i));
		}
		
		int numObjectData = msgQueue.getObjectData().size();
		for (int i = 0; i < numObjectData; ++i) {
			objectData.add(msgQueue.getObjectData().get(i));
		}
		
	}
	
	public IntArray getIntData() {
		return intData;
	}
	
	public ArrayList<Object> getObjectData() {
		return objectData;
	}
	
	public void clear() {
		intData.clear();
		objectData.clear();
	}
	
	public void addParamWithObject(int param, Object object) {
		intData.add(param);
		intData.add(objectData.size());
		objectData.add(object);
	}
	
	public void addParam(int param) {
		intData.add(param);
	}

}
